﻿@{
    ViewBag.Title = "CarUseApp";
    ViewBag.First = "报表中心";
    ViewBag.Second = "申请用车记录";
    Layout = "~/Views/Shared/_BaseLayout.cshtml";
    var list = ViewData["olist"] as IList<Sc.Domain.CommOrgz>;
}
<link href="~/Content/css/select.css" rel="stylesheet" />
<script src="~/Content/laypage-v1.3/laypage/laypage.js"></script>
<script src="~/Content/laydate-v1.1/laydate/laydate.js"></script>
<script src="~/Scripts/select-ui.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        initDate("start", "end", "YYYY/MM/DD hh:mm:ss");
        $(".select2").uedSelect({
            width: 167
        });
        loadData(1,1);
    });
    //数据加载
    function loadData(curr,tag) {
        var url = '@Url.Action("GetCarUseApp")';
        var load = loadTip("数据加载中，请稍候", 16, 0);
        $.get(url, { pageSize: 10, pageIndex: curr, start: $("#start").val(), end: $("#end").val(), orgz: $("#selOrgz").val() }, function (data) {
            $("#listData").find("tr").remove();
            if (tag == 1) {
                initPage(data.PageCount, 1);
                $("#recordCount").html(data.RecordCount);
            }
            var table = document.getElementById("listData");
            $.each(data.Data, function (index, n) {
                var row = table.insertRow(table.rows.length);
                row.insertCell(0).innerHTML = (index + 1);
                row.insertCell(1).innerHTML = n.UserName;
                row.insertCell(2).innerHTML = n.Orgz;
                row.insertCell(3).innerHTML = n.StartAddress;
                row.insertCell(4).innerHTML = n.EndAddress;
                row.insertCell(5).innerHTML = ChangeDateFormat(n.StartTime);
                row.insertCell(6).innerHTML = n.TotalCount;
                row.insertCell(7).innerHTML = n.CarNo;
                row.insertCell(8).innerHTML = n.CarTypeName;
                var statestr = "";
                if (n.InstanceState == 0) {
                    statestr = "创建";
                }
                if (n.InstanceState == 1) {
                    statestr = "审核中";
                }
                if (n.InstanceState == 2) {
                    statestr = "拒绝";
                }
                if (n.InstanceState == 3) {
                    statestr = "通过";
                }
                if (n.InstanceState == 4) {
                    statestr = "已派车";
                }
                if (n.InstanceState == 5) {
                    statestr = "已还车";
                }
                if (n.InstanceState == 6) {
                    statestr = "已取消";
                }
                row.insertCell(9).innerHTML = statestr;
            });
            $('.tablelist tbody tr:odd').addClass('odd');
            $("#currPage").html(curr);
            layer.close(load);
        });
    }

    //初始化分页
    function initPage(pageCount, curr) {
        laypage({
            cont: 'paginList',
            pages: pageCount,
            first: false,
            last: false,
            skip: true,
            curr: curr || 1,
            jump: function (e, first) {
                if (!first) {
                    loadData(e.curr)
                }
            }
        });
    }

    //打印
    function p() {
        $(".scbtn").hide();
        window.print();
        $(".scbtn").show();
    }
</script>
<div id="content" class="rightinfo">
    <div id="tab2" class="tabson">
        <ul class="seachform">
            <li>
                <label>单位</label>
                <div class="vocation">
                    <select name="select" class="select2" id="selOrgz">
                        @foreach (var item in list)
                        {
                            <option value="@item.Id">@item.OrgzName</option>
                        }
                    </select>
                </div>
            </li>
            <li>
                <label>开始时间</label>
                <input type="text" id="start" value="@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd 00:00:00")" readonly="readonly" class="scinput" />
            </li>
            <li>
                <label>结束时间</label>
                <input type="text" value="@DateTime.Now.AddDays(-DateTime.Now.Day + 1).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd 23:59:59")" id="end" readonly="readonly" class="scinput" />
            </li>
            <li>
                <label>&nbsp;</label>
                <input name="Input" type="button" class="scbtn" onclick="loadData(1,1);" value="查询" />
                <label>&nbsp;</label>
                <input name="Input" type="button" class="scbtn" onclick="p();" value="打印" />
            </li>
        </ul>
    </div>
    <table class="tablelist">
        <thead>
            <tr>
                <th width="40px">编号</th>
                <th>用车人</th>
                <th>所在部门</th>
                <th>起点</th>
                <th>终点</th>
                <th>用车时间</th>
                <th>人数</th>
                <th>所派车辆</th>
                <th>车辆类型</th>
                <th>状态</th>
            </tr>
        </thead>
        <tbody id="listData"></tbody>
    </table>
    <div class="pagin">
        <div class="message" style="padding-top:5px;">共&nbsp;<i class="blue" id="recordCount"></i>&nbsp;条记录，当前显示第&nbsp;<i class="blue" id="currPage"></i>&nbsp;页</div>
        <ul class="paginList" id="paginList"></ul>
    </div>
</div>

